package com.ghost.view.Main
{
	import com.ghost.data_struct.HashMap;
	import com.ghost.manager.HDmedia_manager;
	import com.ghost.manager.Load_manager;
	import com.ghost.manager.Sound_manager;
	import com.ghost.manager.Source_manager;
	import com.ghost.manager.UI_manager;
	import com.ghost.model.Configure_url;
	import com.ghost.model.Global_data;
	import com.ghost.model.Loading_data;
	import com.ghost.model.Object_pool;
	import com.ghost.utils.SystemStatus;
	import com.ghost.view.UI.Bottom_exp;
	import com.ghost.view.UI.UI_menu_main;
	import com.ghost.view.UI.UI_top_right;
	import com.ghost.view.chat.Chat_main;
	import com.ghost.view.pop.task.Task_trace;
	
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;

	/**
	 *登录成功后的主容器  
	 * @author ghost
	 */	
	public class Main_mc extends Sprite
	{	
		public function Main_mc()
		{
		}
		/**
		 * 游戏主界面的初始化
		 */		
		public function first_init():void
		{
			Load_manager.get_Instance().add(Configure_url.swf_url+"menu_ui.swf",Loading_data.type_swf,Global_data.loading_des_list["menu_ui.swf"].des_str,menu_ui_Handler);
			//一定要将地图数据存储到图片对象池里
			Load_manager.get_Instance().add(Configure_url.img_url+"map/map_0.png",Loading_data.type_img,"地图1",map_Handler);
			Load_manager.get_Instance().add(Configure_url.img_url+"map/map_1.png",Loading_data.type_img,"地图2",map1_Handler);
			Load_manager.get_Instance().start();
		}
		/**	菜单界面加载完成 */		
		private function menu_ui_Handler(data:Loader):void
		{
			var bottom_menu_h:HashMap = new HashMap();
			bottom_menu_h.put('bottom_role_over',Source_manager.getInstance().getBitmapData('bottom_role_over'));
			bottom_menu_h.put('bottom_role_out',Source_manager.getInstance().getBitmapData('bottom_role_out'));
			bottom_menu_h.put('bottom_pack_over',Source_manager.getInstance().getBitmapData('bottom_pack_over'));
			bottom_menu_h.put('bottom_pack_out',Source_manager.getInstance().getBitmapData('bottom_pack_out'));
			bottom_menu_h.put('bottom_task_over',Source_manager.getInstance().getBitmapData('bottom_task_over'));
			bottom_menu_h.put('bottom_task_out',Source_manager.getInstance().getBitmapData('bottom_task_out'));
			bottom_menu_h.put('bottom_mall_over',Source_manager.getInstance().getBitmapData('bottom_mall_over'));
			bottom_menu_h.put('bottom_mall_out',Source_manager.getInstance().getBitmapData('bottom_mall_out'));
			bottom_menu_h.put('bottom_menu_bg',Source_manager.getInstance().getBitmapData('bottom_menu_bg'));
			Object_pool.loaded_obj_pool.put("bottom_menu_ui",bottom_menu_h);
			var bottom_exp_h:HashMap = new HashMap();
			bottom_exp_h.put('experience_bg',Source_manager.getInstance().getBitmapData('experience_bg'));
			bottom_exp_h.put('experience_left',Source_manager.getInstance().getBitmapData('experience_left'));
			bottom_exp_h.put('experience_view',Source_manager.getInstance().getBitmapData('experience_view'));
			bottom_exp_h.put('experience_right',Source_manager.getInstance().getBitmapData('experience_right'));
			Object_pool.loaded_obj_pool.put("bottom_exp_ui",bottom_exp_h);
			var task_trace_h:HashMap = new HashMap();
			task_trace_h.put('task_trace_bg',Source_manager.getInstance().getBitmapData('task_trace_bg'));
			Object_pool.loaded_obj_pool.put("task_trace_ui",task_trace_h);
		}
		/**	地图加载完成 */	
		private function map_Handler(data:Loader):void
		{
			/*this.addChild(Bitmap(data.content));
			data.width = Global_data.stage_s_width;
			data.height = Global_data.stage_s_height;*/
		}
		private function map1_Handler(data:Loader):void
		{
			var b:Bitmap = new Bitmap();
			b = Bitmap(data.content);
			this.addChild(b);
			b.alpha = 1;
			var bottom_exp:Bottom_exp = new Bottom_exp();
			var task_trace:Task_trace = new Task_trace();
			//var ui_chat:Chat_main = new Chat_main();
			var ui_m:UI_menu_main = new UI_menu_main();
			var sys:SystemStatus = new SystemStatus();
			var ui_top_right:UI_top_right = new UI_top_right();
			UI_manager.getInstance().creat_ui(task_trace);
			UI_manager.getInstance().creat_ui(bottom_exp);
			UI_manager.getInstance().creat_ui(sys);
			UI_manager.getInstance().creat_ui(ui_top_right);
			//UI_manager.getInstance().creat_ui(ui_chat);
			UI_manager.getInstance().creat_ui(ui_m);
			HDmedia_manager.getInstance().play_m4a(Configure_url.sound_url+"bg1.m4a");
		}
	}
}